package com.sgcc.epri.dcloud.controller;

import com.sgcc.epri.dcloud.pojo.FractureSurfaceOrc;
import com.sgcc.epri.dcloud.pojo.Result;
import com.sgcc.epri.dcloud.pojo.SectionOrc;
import com.sgcc.epri.dcloud.service.FractureSurfaceOrcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/fractureSurfaceOrc")
@Api(description = "断面的资产id和设备id映射")
public class FractureSurfaceOrcController {

    @Autowired
    private FractureSurfaceOrcService fractureSurfaceOrcService;

    @GetMapping("/select")
    public Result selectData(@RequestParam(value = "page",required = true)@ApiParam(value = "页数 ", name = "page", required = true) Integer page,
                             @RequestParam(value = "limit",required = true)@ApiParam(value = "条数 ", name = "limit", required = true) Integer limit,
                             @RequestParam(value = "key",required = false)@ApiParam(value = "模糊查询", name = "key", required = false) String key) {
        return fractureSurfaceOrcService.selectData(page, limit ,key);
    }

    @PostMapping("/insert")
    @ApiOperation("新增采用文本框形式，共两个，一个输入以逗号隔开的资产id，一个输入以逗号隔开的设备id。")
    private Result insertData(@RequestBody SectionOrc sectionOrc){
        return fractureSurfaceOrcService.insertData(sectionOrc);
    }

    @PostMapping("/update")
    public Result updateData(@RequestBody FractureSurfaceOrc fractureSurfaceOrc){
        return fractureSurfaceOrcService.updateData(fractureSurfaceOrc);
    }

    @DeleteMapping("/delete")
    private Result deleteData(@RequestParam(name = "id", required = true) @ApiParam(required = true) String id){
        return fractureSurfaceOrcService.deleteData(id);
    }
}
